
	
package net.chathu.airgw 
{
	import net.chathu.airgw.model.IrcModePrefix;
	import net.chathu.airgw.model.JoinedRoomInfo;
	import net.chathu.airgw.model.Room;
	import net.chathu.airgw.model.SessionData;
	import net.chathu.airgw.model.User;
	/**
	 * ...
	 * @author ze
	 */

	
	public class PrefixManager 
	{
		/*
		+%@~&		//hasznalhato prefixek
		vhoqa		//prefixekhez tartozo userMode-ok
		
		Priority:
			IMP_OWNER >> IMP_ROOM_MODERATOR >> IMP_FRIEND >> IMP_IGNORED
		*/
		
		private static var IMP_FRIEND:IrcModePrefix = new IrcModePrefix("v", "+");
		private static var IMP_OWNER:IrcModePrefix = new IrcModePrefix("q", "~");
		private static var IMP_ROOM_MODERATOR:IrcModePrefix = new IrcModePrefix("o", "@");
		private static var IMP_IGNORED:IrcModePrefix = new IrcModePrefix("h", "%");
		
		//hasznalhato lenne meg az "a" (admin/"&") is, de egyelore nincs ra szukseg
		
		//channel voice = +v = +
		//channel operator = +o = @
		//channel owner = +q = ~
		//channel admin = +a = &
		//channel halfop = +h = %
		

		
		public static function getPrefix(session:SessionData, user:User, jri:JoinedRoomInfo):String {
			if (!user)
			{
				return "";
			} else {
				/*return (session.chatData.isFriend(user.regId) ? IMP_FRIEND.prefixChar : "") +
					(session.chatData.isIgnored(user.regId) ? IMP_IGNORED.prefixChar : "") +
					(jri? (jri.hasUserOwerRights(user) ? IMP_OWNER.prefixChar : (jri.hasUserModeratorRights(user) ? IMP_ROOM_MODERATOR.prefixChar: "")): "");*/
				//egyszerre csak 1 prefix legyen:
				/*return (session.chatData.isFriend(user.regId) ? IMP_FRIEND.prefixChar : null) ||
					(session.chatData.isIgnored(user.regId) ? IMP_IGNORED.prefixChar : null)  ||
					(jri? (jri.hasUserOwerRights(user) ? IMP_OWNER.prefixChar : (jri.hasUserModeratorRights(user) ? IMP_ROOM_MODERATOR.prefixChar: "")): "");*/
				return	(jri? (jri.hasUserOwerRights(user) ? IMP_OWNER.prefixChar : (jri.hasUserModeratorRights(user) ? IMP_ROOM_MODERATOR.prefixChar: null)): null) ||
						(session.chatData.isFriend(user.regId) ? IMP_FRIEND.prefixChar : null) ||
						(session.chatData.isIgnored(user.regId) ? IMP_IGNORED.prefixChar : "");
			}
		}
		
		public static function getUserModes(session:SessionData, user:User, jri:JoinedRoomInfo):String {
			if (!user)
			{
				return "";
			} else {
				//egyszerre csak 1 mod legyen
				return 	(jri ? (jri.hasUserOwerRights(user) ? IMP_OWNER.modeChar : (jri.hasUserModeratorRights(user) ? IMP_ROOM_MODERATOR.modeChar: null)) : null) ||
						(session.chatData.isFriend(user.regId) ? IMP_FRIEND.modeChar : null) ||
						(session.chatData.isIgnored(user.regId) ? IMP_IGNORED.modeChar : "");
						/*return (session.chatData.isFriend(user.regId) ? IMP_FRIEND.modeChar : null) ||
					   (session.chatData.isIgnored(user.regId) ? IMP_IGNORED.modeChar : null) ||
					   (jri ? (jri.hasUserOwerRights(user) ? IMP_OWNER.modeChar : (jri.hasUserModeratorRights(user) ? IMP_ROOM_MODERATOR.modeChar: "")) : "");*/
				
						/*(session.chatData.isFriend(user.regId) ? IMP_FRIEND.modeChar : "") +
					   (session.chatData.isIgnored(user.regId) ? IMP_IGNORED.modeChar : "") +
					   (jri ? (jri.hasUserOwerRights(user) ? IMP_OWNER.modeChar : (jri.hasUserModeratorRights(user) ? IMP_ROOM_MODERATOR.modeChar: "")) : "");*/
					   //jri lehet null az &users eseten
					   
					   
			}			
		}
	}
	
}
